using System.Collections.ObjectModel;
using HMCollada.Core;
using System.Xml;
using HMCollada.FX;

namespace HMCollada.FX {
    internal struct HMColladaEffect {
        internal string id;
        internal string name;
        internal HMColladaAsset asset;
        internal Collection<HMColladaImage> image;
        internal Collection<HMColladaNewParam> newparam;
        internal HMColladaProfileCOMMON profile;
    }
}

namespace HMCollada {
    internal partial class HMColladaLoader {
        private static HMColladaEffect LoadEffect() {
            HMColladaEffect newEffect = new HMColladaEffect();
            newEffect.id = colladaReader.GetAttribute("id");
            newEffect.name = colladaReader.GetAttribute("name");

            newEffect.image = new Collection<HMColladaImage>();
            newEffect.newparam = new Collection<HMColladaNewParam>();

            if (!colladaReader.IsEmptyElement) colladaReader.Read();
            do {
                if (colladaReader.NodeType != XmlNodeType.EndElement) {
                    switch (colladaReader.Name) {
                        case "asset": newEffect.asset = LoadAsset(); break;
                        case "image": newEffect.image.Add(LoadImage()); break;
                        case "newparam": newEffect.newparam.Add(LoadNewParam()); break;
                        case "profile_COMMON": newEffect.profile = LoadProfileCOMMON(); break;
                    }
                }

                if (!colladaReader.IsEmptyElement) colladaReader.Read();
            } while (colladaReader.Name != "effect");

            if (colladaReader.IsEmptyElement) colladaReader.Read();
            return newEffect;
        }
    }
}